package m2.links;

import java.lang.reflect.Method;

import m2.port.Port;

public class InternalBinding extends Binding{

		/**
		 * 
		 * @param fromPort
		 * @param toPort
		 * @return
		 */
		public final void internalBindingOut(Port fromPort, Method interBindProcessing, Object object, Port toPort){
					
			setAttachIn(new Attachment());
			getAttachIn().connectPortToRole(fromPort, getInternalProvidedRole());
								
			getGlueOut().setGlueProcessing(interBindProcessing, object);		
			getGlueOut().connectProvidedRoleToRequiredRole(getInternalProvidedRole(), getInternalRequiredRole());	
					
			setAttachOut(new Attachment());
			getAttachOut().connectRoleToPort(getInternalRequiredRole(), toPort);
			
		}
		
		/**
		 * 
		 * @param toPort
		 * @param fromPort
		 * @return
		 */
		public final void internalBindingIn(Port toPort, Method interBindProcessing, Object object, Port fromPort){
				
				setAttachOut(new Attachment());
				getAttachOut().connectPortToRole( toPort, getInternalRequiredRole());
				
				getGlueIn().setGlueProcessing(interBindProcessing, object);
				getGlueIn().connectRequiredRoleToProvidedRole(getInternalRequiredRole(), getInternalProvidedRole());	
				
				setAttachIn(new Attachment());
				getAttachIn().connectRoleToPort(getInternalProvidedRole(),fromPort);	
				
		}
}
